#include<vector>
#include<iostream>

using namespace std;

vector<int> leastDistance(vector<int> v1, vector<int> v2) {
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  vector<int> ans {};
  int distance = v2.end() - v1.begin();
  for (int l1 = 0; l1 < v1.size(); l1++) {
    for (int l2 = 0; l2 < v2.size(); l2++) {
      if (abs(v1[l1] - v2[l2]) < distance) {
          ans = {v1[l1], v2[l2]};
        }
      if (v2[l2] >= v1[l1]) {
        break;
      }
    } 
  }
  return ans;
}

int main(int argc, char const *argv[])
{
  vector<int> v1 {-1, 5, 10, 20, 28, 3};
  vector<int> v2 {26, 134, 135, 15, 17};
  for (int i : leastDistance(v1, v2)) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
